package yf.mall.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import java.util.Map;
import com.yf.consts.DaoConst;
import yf.mall.entity.OrderUnionEntity;
import yf.mall.service.OrderUnionService;
import com.yf.response.R;


/**
 * 联合订单Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Tue Jun 30 11:45:42 CST 2020
 */
@RestController
@RequestMapping("/order/union")
public class OrderUnionController {
    @Autowired
    private OrderUnionService orderUnionService;

    /**
     * 列表联合订单
     */
    @RequestMapping("/list")
    @RequiresPermissions("order:union:list")
    public R list(@RequestParam Map<String,Object> params) {
        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<OrderUnionEntity> orderUnionList = orderUnionService.queryList(params);
        return R.ok(new PageInfo(orderUnionList));
    }

    /**
     * z
     */
    @SysLog("查看联合订单")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("order:union:info")
    public R info(@PathVariable("id") Long id) {
        OrderUnionEntity orderUnion = orderUnionService.get(id);

        return R.ok(orderUnion);
    }

    /**
     * 保存联合订单
     */
    @SysLog("保存联合订单")
    @RequestMapping("/save")
    @RequiresPermissions("order:union:save")
    public R save(OrderUnionEntity orderUnion) {
        orderUnionService.save(orderUnion);

        return R.ok(orderUnion);
    }

    /**
     * 修改联合订单
     */
    @SysLog("修改联合订单")
    @RequestMapping("/update")
    @RequiresPermissions("order:union:update")
    public R update(OrderUnionEntity orderUnion) {
        orderUnionService.update(orderUnion);

        return R.ok(orderUnion);
    }

    /**
     * 删除联合订单
     */
    @SysLog("删除联合订单")
    @RequestMapping("/delete")
    @RequiresPermissions("order:union:delete")
    public R delete(Long[]ids) {
        orderUnionService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有联合订单
     */
    @SysLog("所有联合订单")
    @RequestMapping("/queryAll")
    public R queryAll (@RequestParam Map<String,Object> params) {

        List<OrderUnionEntity> orderUnionList = orderUnionService.queryList(params);

        return R.ok(orderUnionList);
    }

    /**
    @ModelAttribute
    public SearchParam<OrderUnionEntity> searchParam(SearchParam<OrderUnionEntity> params, OrderUnionEntity orderUnion) {
        if (orderUnion != null) {
            params.setEntity(orderUnion);
        }

        return params;
    }
 **/
    /***********自定义开始***********/
}
